package view;

import javax.swing.JFrame;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

import control.Control;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class FrontCoverWindow extends JFrame {
	
	private JLabel imageLabel=new JLabel();
	private ImageIcon frontCover=null;
	
	protected FrontCoverWindow () {
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	}
	
	//sets the only content(an image)
	protected void setFrontCover(byte[] imageData){
		if(this.getContentPane().isAncestorOf(imageLabel))this.getContentPane().remove(imageLabel);
		frontCover=new ImageIcon(imageData);
		imageLabel=new JLabel(frontCover);
		this.getContentPane().setLayout(new BorderLayout());
		this.getContentPane().add(imageLabel, BorderLayout.CENTER);
		this.setSize(frontCover.getIconWidth(),frontCover.getIconHeight());
	}
	
}
